<template>
    <div>
        <table>
            <tbody>
                <tr>
                    <td>名称</td>
                    <td>
                        <input type="text" v-model="date.name">
                    </td>
                </tr>
                <tr>
                    <td>日期</td>
                    <td>
                        <input type="date" v-model="date.dates">
                    </td>
                </tr>
                <tr>
                    <td>数量</td>
                    <td>
                        <input type="text" v-model="date.num">
                    </td>
                </tr>
                <tr>
                    <td>房态</td>
                    <td>
                        <input type="radio" value="1" name="houses" v-model="date.houses">开房
                        <input type="radio" value="2" name="houses" v-model="date.houses">闭防
                        <input type="radio" value="3" name="houses" v-model="date.houses">维修
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="button" value="新增" @click="add">
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router';
import axios from 'axios';
import { ref } from 'vue';
const routher = useRouter()

const add=()=>{
    axios.post("https://localhost:7238/api/House/AddHouse",date.value).then(res=>{
        if(res.data>0){
            alert("新增成功")
            routher.push({path:"/Show"})
        }
        else{
            alert("新增失败")
        }
    })
}
const date=ref({
  "id": 0,
  "name": "",
  "dates": "",
  "num": "",
  "houses": 0
})
</script>

<style scoped>

</style>